package poker;
import java.util.Random;
import java.util.ArrayList;

/** KLASA Deck - TALIA. */
public class Deck {

  /** LISTA KART. */
  private ArrayList<Card> cards;

  /** KONSTRUKTOR KLASY Deck. */
  Deck() {
	  
  	int index1, index2;
    cards = new ArrayList<Card>();
	final Random generator=new Random();
	Card temp;

	/** DODAWANIE KART DO TALII. */
	for (int a = 1; a < 5; a++) { 
	  for (int b = 1; b< 14; b++) {
	    cards.add(new Card(a, b));
      }
	}

	/** TASOWANIE TALII (100-KROTNA ZAMIANA DWOCH LOSOWYCH KART). */
	for (int i = 0; i < 100; i++) {
      index1 = generator.nextInt(cards.size() - 1);
	  index2 = generator.nextInt(cards.size() - 1);
	  temp = cards.get(index2);
	  cards.set(index2, cards.get(index1));
	  cards.set(index1, temp);
	}
  }

  /** @return KARTA Z WIERZCHU, KTORA PO POBRANIU JEST USUNIETA. */
  public Card drawFromDeck() {
    return cards.remove(0);
  }

  /** @return POZOSTALA W TALII ILOSC KART. */
  public int getTotalCards() {
    return cards.size();
  }

}